<?php

use Phinx\Migration\AbstractMigration;

class CreateProductCategory extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('product_category', ['id' => 'category_id']);
        $table->addColumn('name', 'string', ['limit' => 50, 'comment' => '分类名称'])
            ->addColumn('parent_id', 'integer', ['default' => 0, 'comment' => '父级ID'])
            ->addColumn('level', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '层级'])
            ->addColumn('icon', 'string', ['limit' => 255, 'null' => true, 'comment' => '图标'])
            ->addColumn('description', 'string', ['limit' => 255, 'null' => true, 'comment' => '描述'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态：0=禁用，1=启用'])
            ->addColumn('sort', 'integer', ['default' => 0, 'comment' => '排序'])
            ->addColumn('created_at', 'timestamp', ['null' => true])
            ->addColumn('updated_at', 'timestamp', ['null' => true])
            ->addIndex(['parent_id'])
            ->addIndex(['status'])
            ->create();
    }
} 